package.cpath = "./?.so;"
package.path = "./?.lua"

local lua_memdb = require "lua_memdb"

local function tt()
    local a = lua_memdb.create_memdb_client()
    print("create= ", a)

    local b  = a:connect_memdb("192.168.202.92", 12515)
    print("connect_memdb = ", b)

    --[[
    local i = 0
    while true do
        i = i + 1
        local h1 = a:get_user_data(215698)
        print("h1=", h1)
        print("i=", i)
    end
    --]]
    local h1 = a:get_user_data(287174)
    print("h1=", h1)

    local after_money = a:update_user_money(287174, -1000)
    print("after_money=", after_money)

    local h2= a:get_user_data(287174)
    print("h2=", h2)
end

--tt()

local M = {
    memdb_t = {},
    index = 0,
}
local function t2()
    if M.memdb_t["test"] then
       -- M.memdb_t["test"]:__gc()
    end

    local c = lua_memdb.create_memdb_client()
    local ret = c:connect_memdb("192.168.202.92", 12515)
    if ret==0 then
        M.memdb_t["test"] = c
        M.index = M.index + 1
        --print(M.index)
    end
end

while true do
    t2()
    --os.execute("sleep 1")
end
